package com.ytd.smartcanteen.weighting.util;

import com.ytd.common.bean.BaseRequest;
import com.ytd.smartcanteen.weighting.bean.MealInfo;
import com.ytd.smartcanteen.weighting.bean.OrderBean;
import com.ytd.smartcanteen.weighting.bean.request.GetConsumeRequestData;
import com.ytd.smartcanteen.weighting.bean.request.LoginRequestData;
import com.ytd.smartcanteen.weighting.bean.request.UpdateFoodInfoRequestData;
import com.ytd.smartcanteen.weighting.constants.Constants;

import java.util.List;
import java.util.Objects;

/**
 * Your class notes
 *
 * @author gaoguanchao
 * @since 2023/4/21
 */
public class RequestUtil {
    public static BaseRequest getConsume(String trayId) {
        GetConsumeRequestData data = new GetConsumeRequestData();
        data.trayId = trayId;
        return getBaseRequest(Constants.GET_CONSUME, data);
    }

    public static BaseRequest getLogin(String password) {
        LoginRequestData data = new LoginRequestData();
        data.password = password;
        return getBaseRequest(Constants.MERCHANT_LOGIN, data);
    }

    public static BaseRequest batchAddOrder(List<OrderBean> localOrder) {
        return getBaseRequest(Constants.BATCH_ADD_ORDER, localOrder);
    }

    private static BaseRequest getBaseRequest(String interfaceName, Object data) {
        BaseRequest request = new BaseRequest();
        request.interfaceName = interfaceName;
        request.data = data;
        return request;
    }

    public static BaseRequest updateFoodInfo(String mealTimeId, MealInfo mealInfo) {
        UpdateFoodInfoRequestData requestData = new UpdateFoodInfoRequestData();
        requestData.foodId = mealInfo.foodId;
        requestData.mealTimeId = mealTimeId;
        return getBaseRequest(Constants.UPDATE_FOOD_INFO, requestData);
    }
}
